// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  hash: true,
  history: {
    type: 'hash',
  },
  antd: {},
  dva: {
    hmr: true,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      component: '../layouts/UserLayout',
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },
    {
      path: '/',
      component: '../layouts/SecurityLayout',
      routes: [
        {
          path: '/',
          component: '../layouts/BasicLayout',
          authority: ['admin', 'user'],
          routes: [
            {
              path: '/',
              redirect: './user/login',
            },
            {
              path: '/welcome',
              name: 'home',
              icon: 'smile',
              component: './Dashboard',
              authority: ['admin', 'user'],
            },
            {
              name: 'monitor',
              icon: 'monitor',
              path: '/monitor',
              authority: ['admin', 'user'],
              routes: [
                {
                  name: 'api',
                  icon: 'monitor',
                  path: '/monitor/api',
                  authority: ['admin', 'user'],
                  routes: [
                    {
                      name: 'health',
                      icon: 'monitor',
                      path: '/monitor/api/health',
                      component: './HealthCheckList',
                      authority: ['admin', 'user'],
                    },
                    {
                      name: 'log',
                      icon: 'monitor',
                      path: '/monitor/api/log',
                      component: './APIExceptionLogList',
                      authority: ['admin', 'user'],
                    },
                  ],
                },
                {
                  name: 'speed',
                  icon: 'monitor',
                  path: '/monitor/monitorList',
                  component: './MonitorList',
                  authority: ['admin', 'user'],
                },
              ],
            },
            {
              path: '/asster',
              name: 'asster',
              icon: 'cloudServer',
              authority: ['admin'],
              routes: [
                {
                  path: '/asster/server',
                  name: 'server',
                  icon: 'cloudServer',
                  component: './ServerAssterList',
                  authority: ['admin'],
                },
                {
                  path: '/asster/domain',
                  name: 'domain',
                  icon: 'cloudServer',
                  component: './DomainList',
                  authority: ['admin', 'user'],
                },
              ],
            },
            {
              path: '/ESIndex',
              name: 'ESIndex',
              icon: 'database',
              authority: ['admin'],
              routes: [
                {
                  path: '/ESIndex/esIndexList',
                  name: 'esIndexList',
                  icon: 'database',
                  component: './ESIndexList',
                  authority: ['admin'],
                },
                {
                  path: '/ESIndex/esProIndexList',
                  name: 'esProIndexList',
                  icon: 'database',
                  component: './ESProIndexList',
                  authority: ['admin'],
                },
              ],
            },
            {
              path: '/job',
              name: 'job',
              icon: 'monitor',
              authority: ['admin'],
              routes: [
                {
                  path: '/job/detail',
                  name: 'detail',
                  icon: 'monitor',
                  component: './JobList',
                  authority: ['admin'],
                },
                {
                  path: '/job/log',
                  name: 'log',
                  icon: 'monitor',
                  component: './JobLogList',
                  authority: ['admin'],
                },
              ],
            },
            {
              path: '/setting',
              name: 'system',
              icon: 'setting',
              authority: ['admin'],
              routes: [
                {
                  path: '/setting/user',
                  name: 'user',
                  icon: 'user',
                  component: './UserList',
                  authority: ['admin'],
                },
              ],
            },
            {
              component: './404',
            },
          ],
        },
        {
          component: './404',
        },
      ],
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
});
